<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="keywords" content="test" />
    <meta name="description" content="" />
    <title>IOS Install</title>
    <link rel="stylesheet" type="text/css" href="style/css/mobile.css" />
    <style>
        .doc {
            text-align: center;
            margin-top: 50px;
        }
    </style>
</head>
<body>
    <div class="doc">
        <p><a id="downloadLink" href="itms-services://?action=download-manifest&url=https://gitee.com/guan_lx/glx/blob/master/ios_download.plist">Download</a></p>
    </div>

    <script>
        // 获取下载链接元素
        const downloadLink = document.getElementById('downloadLink');

        // 监听点击事件
        downloadLink.addEventListener('click', function (event) {
            event.preventDefault(); // 阻止默认跳转行为

            // 记录当前时间
            const startTime = Date.now();

            // 尝试打开 itms-services 链接
            window.location.href = downloadLink.href;

            // 设置一个定时器，检测页面是否跳转
            setTimeout(function () {
                // 如果页面没有跳转（仍在当前页面）
                if (Date.now() - startTime < 1000) { // 1秒内未跳转
                    alert('Failed to launch the download. Please ensure you are using an iOS device and Safari browser.');
                }
            }, 1000); // 1秒后检测
        });
    </script>
</body>
</html>